package cn.uexpo.lhz.biz.impl;

import java.util.List;
import java.util.Map;

import cn.uexpo.lhz.domain.vo.EventVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.biz.EventBiz;
import cn.uexpo.lhz.dao.EventMapper;
import cn.uexpo.lhz.domain.Event;
import cn.uexpo.lhz.domain.EventExample;


@Service
public class EventBizImpl  implements EventBiz {


	@Autowired
	private  EventBiz eventBiz;

	@Autowired
	private EventMapper eventMapper;

	@Override
	public int insert(Event record) throws BOException {
		return eventMapper.insert(record);
	}

	@Override
	public int insertSelective(Event record) throws BOException {
		return eventMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		return eventMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(Event record) throws BOException {
		return eventMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		for (Integer id : ids) {
			eventMapper.deleteByPrimaryKey(id);
		}
		return 1;
	}

	@Override
	public int delete(List<Event> records) throws BOException {
		for (Event record : records) {
			eventMapper.deleteByPrimaryKey(record.getId());
		}
		return 1;
	}

	@Override
	public int deleteByExample(EventExample example) throws BOException {
		return eventMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(Event record) throws BOException {
		return eventMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(Event record) throws BOException {
		return eventMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(Event record, EventExample example) throws BOException {
		return eventMapper.updateByExampleSelective(record,example);
	}

	@Override
	public int updateByExample(Event record, EventExample example) throws BOException {
		return eventMapper.updateByExample(record,example);
	}

	@Override
	public Event selectByPrimaryKey(Integer id) throws BOException {
		return eventMapper.selectByPrimaryKey(id);
	}

	@Override
	public Event selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Event> selectByExample(EventExample example) throws BOException {
		return eventMapper.selectByExample(example);
	}

	@Override
	public long countByExample(EventExample example) throws BOException {
		return eventMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, EventExample example) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
	    List<Event> records = (List<Event>) eventMapper.selectByExample(example);
	    return PageUtils.getPageResult(pageRequest, new PageInfo<Event>(records));
	}

	@Override
	public Event selectArea(Event record) {
		return eventMapper.selectArea(record);
	}

	@Override
	public List<Event> selectVague(Event record) {
		return eventMapper.selectVague(record);
	}

	@Override
	public List<Event> selectVagueN() {

		return eventMapper.selectVagueN();
	}

	@Override
	public List<Event> selectEventDependencyAllByEventID(Event record) {
		return eventMapper.selectEventDependencyAllByEventID(record);
	}

	@Override
	public List<Event> selectByEventIdAndActivityName(Event record) {
		// TODO Auto-generated method stub
		return eventMapper.selectByEventIdAndActivityName(record);
	}

	@Override
	public List<Map> selectEventName() {
		// TODO Auto-generated method stub
		return eventMapper.selectEventName();
	}

	@Override
	public  PageResult selectByEventName(PageRequest pageRequest,Event record){
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
		PageHelper.startPage(pageNum, pageSize);
		List<Event>  records=eventMapper.selectByEventName(record);
		return PageUtils.getPageResult(pageRequest, new PageInfo<Event>(records));
	}

	@Override
	public int selectByEventNameCount(Event record) {
		return eventMapper.selectByEventNameCount(record);
	}



	@Override
	public PageResult selectByEventName2(PageRequest pageRequest,Event record) {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
		PageHelper.startPage(pageNum, pageSize);
		List<Event>  records=eventMapper.selectByEventName2(record);
		return  PageUtils.getPageResult(pageRequest, new PageInfo<Event>(records));
	}

	@Override
	public Integer getName(String name) {
		Integer name1 = eventBiz.getName(name);
		return name1;
	}

	@Override
	public int selectByEventNameCount2(EventVo record) {
		return eventMapper.selectByEventNameCount2(record);
	}

	@Override
	public PageResult selectByEventName3(PageRequest pageRequest, EventVo record) {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
		PageHelper.startPage(pageNum, pageSize);
		List<Event>  records=eventMapper.selectByEventName3(record);
		return  PageUtils.getPageResult(pageRequest, new PageInfo<Event>(records));
	}

	@Override
	public int deleteByID(Integer id) {
		return eventMapper.deleteByID(id);
	}


}
